Skip to content

Feat: startAsync and StopAsync callbacks - #1629

Open
dorjesinpo wants to merge 1 commit into
mainfrom
dev/start-stop-callbacks
Open

Feat: startAsync and StopAsync callbacks#1629
dorjesinpo wants to merge 1 commit into
mainfrom
dev/start-stop-callbacks

Conversation

@dorjesinpo

Copy link
Copy Markdown
Collaborator

Add completion-callback overloads to bmqa async session start/stop

bmqa::Session::startAsync/stopAsync previously reported completion only via
session events, unlike the rest of the async API (openQueueAsync et al.) which
take a completion callback. Add callback-taking overloads that deliver a typed
status to a user callback, mirroring the openQueueAsync pattern.

  • New value types bmqa::StartStatus / bmqa::StopStatus (result + error
    description), registered in package/bmqa.mem.
  • New virtuals in AbstractSession; implemented in Session and MockSession.
  • bmqimp: BrokerSession caches the callback on entering STARTING
    (handleStartRequest) / on accepting a stop (handleStopRequest), and attaches
    it to the terminal event (CONNECTED, CONNECTION_TIMEOUT, DISCONNECTED),
    suppressing that session event and delivering it to the callback instead
    (as openQueueAsync does). Callback runs on the event-delivery thread, never
    the FSM thread. resetState clears any callback that never rode a terminal
    event, preventing leaks across start/stop cycles.
  • Non-callback path is unchanged.

Tests: value-semantics tests for Start/StopStatus; MockSession callback case;
BrokerSession real-FSM case asserting the callback fires and the terminal
session event is suppressed.

@dorjesinpo
dorjesinpo requested a review from a team as a code owner July 20, 2026 17:42
@dorjesinpo dorjesinpo added the enhancement New feature or request label Jul 20, 2026
@dorjesinpo
dorjesinpo force-pushed the dev/start-stop-callbacks branch from f951cf4 to 0113c6c Compare July 20, 2026 17:45
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v21.1.8) reports: 20 concern(s)
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:168:5: error: [cppcoreguidelines-pro-type-member-init]

    constructor does not initialize these fields: d_receivedSessionEvents, d_receivedResults, d_receivedStartResults, d_receivedStopResults, d_receivedMessageEvents, d_assertsInvoked

      101 |     EventHandler(bslma::Allocator* allocator)
          |     ^
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1565:38: error: [cppcoreguidelines-init-variables]

    variable 'startCallback' is not initialized

     1565 |     bmqa::MockSession::StartCallback startCallback =
          |                                      ^
     1566 |         bdlf::MemFnUtil::memFn(&EventHandler::onStartStatus, &eventHandler);
          |                                                            
          |                                                             = 0
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1568:37: error: [cppcoreguidelines-init-variables]

    variable 'stopCallback' is not initialized

     1568 |     bmqa::MockSession::StopCallback stopCallback =
          |                                     ^
     1569 |         bdlf::MemFnUtil::memFn(&EventHandler::onStopStatus, &eventHandler);
          |                                                           
          |                                                            = 0
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1635:10: error: [cppcoreguidelines-avoid-magic-numbers]

    9 is a magic number; consider replacing it with a named constant

     1635 |     case 9: test9_startStopAsyncCallback(); break;
          |          ^
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1636:10: error: [cppcoreguidelines-avoid-magic-numbers]

    8 is a magic number; consider replacing it with a named constant

     1636 |     case 8: test8_postBlockedToSuspendedQueue(); break;
          |          ^
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1637:10: error: [cppcoreguidelines-avoid-magic-numbers]

    7 is a magic number; consider replacing it with a named constant

     1637 |     case 7: test7_postAndAccess(); break;
          |          ^
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1638:10: error: [cppcoreguidelines-avoid-magic-numbers]

    6 is a magic number; consider replacing it with a named constant

     1638 |     case 6: test6_runThrough(); break;
          |          ^
  • src/groups/bmq/bmqa/bmqa_mocksession.t.cpp:1639:10: error: [cppcoreguidelines-avoid-magic-numbers]

    5 is a magic number; consider replacing it with a named constant

     1639 |     case 5: test5_confirmingMessages(); break;
          |          ^
  • src/groups/bmq/bmqa/bmqa_startstatus.t.cpp:209:5: error: [bugprone-branch-clone]

    repeated branch body in conditional chain

      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:559:5: note: expanded from macro 'TEST_PROLOG'
      559 |     INIT_BALL_LOGGING();                                                      \
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:573:60: note: expanded from macro 'INIT_BALL_LOGGING'
      573 |         if (bmqtst::TestHelperUtil::verbosityLevel() == 1) {                  \
          |                                                            ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqa/bmqa_startstatus.t.cpp:209:5: note: clone 1 starts here
      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:559:5: note: expanded from macro 'TEST_PROLOG'
      559 |     INIT_BALL_LOGGING();                                                      \
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:576:65: note: expanded from macro 'INIT_BALL_LOGGING'
      576 |         else if (bmqtst::TestHelperUtil::verbosityLevel() == 2) {             \
          |                                                                 ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqa/bmqa_startstatus.t.cpp:209:5: note: clone 2 starts here
      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:559:5: note: expanded from macro 'TEST_PROLOG'
      559 |     INIT_BALL_LOGGING();                                                      \
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:579:65: note: expanded from macro 'INIT_BALL_LOGGING'
      579 |         else if (bmqtst::TestHelperUtil::verbosityLevel() >= 3) {             \
          |                                                                 ^
  • src/groups/bmq/bmqa/bmqa_startstatus.t.cpp:209:5: error: [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    do not use pointer arithmetic

      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:549:64: note: expanded from macro 'TEST_PROLOG'
      549 |     const int _testCase                      = argc > 1 ? atoi(argv[1]) : 0;  \
          |                                                                ^
  • src/groups/bmq/bmqa/bmqa_stopstatus.t.cpp:209:5: error: [bugprone-branch-clone]

    repeated branch body in conditional chain

      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:559:5: note: expanded from macro 'TEST_PROLOG'
      559 |     INIT_BALL_LOGGING();                                                      \
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:573:60: note: expanded from macro 'INIT_BALL_LOGGING'
      573 |         if (bmqtst::TestHelperUtil::verbosityLevel() == 1) {                  \
          |                                                            ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqa/bmqa_stopstatus.t.cpp:209:5: note: clone 1 starts here
      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:559:5: note: expanded from macro 'TEST_PROLOG'
      559 |     INIT_BALL_LOGGING();                                                      \
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:576:65: note: expanded from macro 'INIT_BALL_LOGGING'
      576 |         else if (bmqtst::TestHelperUtil::verbosityLevel() == 2) {             \
          |                                                                 ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqa/bmqa_stopstatus.t.cpp:209:5: note: clone 2 starts here
      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:559:5: note: expanded from macro 'TEST_PROLOG'
      559 |     INIT_BALL_LOGGING();                                                      \
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:579:65: note: expanded from macro 'INIT_BALL_LOGGING'
      579 |         else if (bmqtst::TestHelperUtil::verbosityLevel() >= 3) {             \
          |                                                                 ^
  • src/groups/bmq/bmqa/bmqa_stopstatus.t.cpp:209:5: error: [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    do not use pointer arithmetic

      209 |     TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT);
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqtst/bmqtst_testhelper.h:549:64: note: expanded from macro 'TEST_PROLOG'
      549 |     const int _testCase                      = argc > 1 ? atoi(argv[1]) : 0;  \
          |                                                                ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9763:5: error: [cppcoreguidelines-pro-type-member-init]

    constructor does not initialize these fields: d_sem

     9759 |     bslmt::TimedSemaphore        d_sem;
          |                                       
          |                                       {}
     9760 |     bmqt::SessionEventType::Enum d_type;
     9761 |     int                          d_status;
     9762 | 
     9763 |     SessionCbRecorder()
          |     ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9880:10: error: [cppcoreguidelines-avoid-magic-numbers]

    71 is a magic number; consider replacing it with a named constant

     9880 |     case 71: test71_startStopAsyncCallback(); break;
          |          ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9881:5: error: [bugprone-branch-clone]

    switch has 2 consecutive identical branches

     9881 |     case 70: /* removed test */ break;
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9882:38: note: last of these clones ends here
     9882 |     case 69: /* removed test */ break;
          |                                      ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9881:10: error: [cppcoreguidelines-avoid-magic-numbers]

    70 is a magic number; consider replacing it with a named constant

     9881 |     case 70: /* removed test */ break;
          |          ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9882:10: error: [cppcoreguidelines-avoid-magic-numbers]

    69 is a magic number; consider replacing it with a named constant

     9882 |     case 69: /* removed test */ break;
          |          ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9883:10: error: [cppcoreguidelines-avoid-magic-numbers]

    68 is a magic number; consider replacing it with a named constant

     9883 |     case 68: test68_queueLateAsyncCanceledHybrid3(); break;
          |          ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9884:5: error: [bugprone-branch-clone]

    switch has 2 consecutive identical branches

     9884 |     case 67: /* removed test */ break;
          |     ^
    /home/runner/work/blazingmq/blazingmq/src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9885:38: note: last of these clones ends here
     9885 |     case 66: /* removed test */ break;
          |                                      ^
  • src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp:9884:10: error: [cppcoreguidelines-avoid-magic-numbers]

    67 is a magic number; consider replacing it with a named constant

     9884 |     case 67: /* removed test */ break;
          |          ^

Have any feedback or feature suggestions? Share it here.

@dorjesinpo dorjesinpo changed the title startAsync and StopAsync callbacks Feat: startAsync and StopAsync callbacks Jul 20, 2026
@dorjesinpo
dorjesinpo force-pushed the dev/start-stop-callbacks branch 3 times, most recently from 450c919 to fd2f006 Compare July 20, 2026 18:10
@dorjesinpo
dorjesinpo requested a review from pniedzielski July 20, 2026 18:50
@pniedzielski
pniedzielski force-pushed the dev/start-stop-callbacks branch from fd2f006 to c363fe9 Compare July 30, 2026 19:51
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
@dorjesinpo
dorjesinpo force-pushed the dev/start-stop-callbacks branch from c363fe9 to 43f2917 Compare July 31, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants